#include <iostream>
#include <fstream>
#include <string>
#include "bundle.h"
using namespace std;


int main(int argc,char* argv[])
{
    //打开文件
    ifstream ifs;
    ifs.open(argv[1],std::ios::binary);

    ifs.seekg(0,ios::end);
    size_t size = ifs.tellg();
    ifs.seekg(0,ios::beg);

    string body;
    body.resize(size);
    
    //获取文件内容

    ifs.read(&body[0],size);
    ifs.close();
    //解压缩
    string unpacked = bundle::unpack(body);

    //写入普通文件
    ofstream ofs;
    ofs.open(argv[2],ios::binary);
    ofs.write(unpacked.c_str(),unpacked.size());

    ofs.close();
    return 0;
}